
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
    <form class="layui-form" action="">
        <input type="hidden" name="dept_id" value="{$dept_id}"/>
        <input type="hidden" name="dept_name" value="{$dept_name}"/>
        <div class="mainBox">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" maxlength="30" name="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">昵称</label>
                    <div class="layui-input-block">
                        <input type="text"  name="nickname" placeholder="请输入昵称"  lay-verify="required" autocomplete="off"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">工号</label>
                    <div class="layui-input-block">
                        <input type="text"  name="job_number" placeholder="请输入工号" autocomplete="off"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">职位</label>
                    <div class="layui-input-block">
                        <select class="layui-input-block" name="profession_id">
                            <option value="">请选择</option>
                            {foreach name="profession" item="vo"}
                            <option value="{$vo['id']}">{$vo['name']}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">直属上级</label>
                    <div class="layui-input-block">
                        <select class="layui-input-block" name="leader_id">
                            <option value="">请选择</option>
                            {foreach name="user" item="vo"}
                            <option value="{$vo['id']}">{$vo['username']}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio"  name="sex" value="1" title="男" checked>
                        <input type="radio"  name="sex" value="2" title="女">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="password"  placeholder="请输入密码"  lay-verify="required" autocomplete="off"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">入职日期</label>
                    <div class="layui-input-block">
                        <input type="text"  name="induction_date" placeholder="请输入日期"  autocomplete="off"  class="layui-input" id="induction_date">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">年假天数</label>
                    <div class="layui-input-block">
                        <input type="number"  name="year_holidays" placeholder="年假天数"  autocomplete="off"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">试用期至</label>
                    <div class="layui-input-block">
                        <input type="text"  name="probation" placeholder="试用期截止时间" autocomplete="off"  class="layui-input" id="probation">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否转正</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_formal" value="1" title="是" checked>
                        <input type="radio" name="is_formal" value="2" title="否">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">在职状态</label>
                    <div class="layui-input-block">
                        <input type="radio" lay-filter="job_status" name="job_status" value="1" title="在职" checked>
                        <input type="radio" lay-filter="job_status" name="job_status" value="2" title="离职">
                    </div>
                </div>
                <div id="extend" style="display: none">
                    <div class="layui-form-item">
                        <label class="layui-form-label">离职日期</label>
                        <div class="layui-input-block">
                            <input type="text"  name="quit_date" placeholder="离职日期" autocomplete="off"  class="layui-input" id="quit_date">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">离职原因</label>
                        <div class="layui-input-block">
                            <textarea class="layui-input" name="quit_reason" style="height: 150px"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery', 'laydate'],function(){
    let form = layui.form;
    let laydate = layui.laydate;
    let $ = layui.jquery;

    laydate.render({
        elem: '#induction_date',
        type: 'date'
    });

    laydate.render({
        elem: '#probation',
        type: 'date'
    });

    laydate.render({
        elem: '#quit_date',
        type: 'date'
    });

    form.on('submit(save)', function(data){
        $.ajax({
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(res){
               //判断有没有权限
                if(res && res.code==999){
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 2000, 
                    })
                    return false;
                }else if(res.code==200){
                    layer.msg(res.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("dataTable");
                    });
                }else{
                    layer.msg(res.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });

    form.on('radio(job_status)', function (data) {
        if (data.value == 2) {
            $('#extend').show();
        } else {
            $('#extend').hide();
        }
    })
})
</script>
</body>
</html>